/**
 * 文件描述如下：
 * 1. 设备驱动页面的数据
 */

// 处理交通流量页面的数据
const data_1 = {
  title: '场景算法',
  data: [
    {
      id: 0,
      key: 'max-acceleration',
      parentNode: 'algorithm/lane-change',
      name: '最大加速度',
      showType: 'input',
      inputType: 'double',
    },
    {
      id: 1,
      key: 'max-deceleration',
      parentNode: 'algorithm/lane-change',
      name: '最大减速度',
      showType: 'input',
      inputType: 'double',
    },
    {
      id: 2,
      key: 'min-abs-time-span',
      parentNode: 'algorithm/lane-change',
      name: '最小安全时距',
      showType: 'input',
      inputType: 'double',
    },
    {
      id: 3,
      key: 'min-merge-speed',
      parentNode: 'algorithm/lane-change',
      name: '最小汇入速度',
      showType: 'input',
      inputType: 'double',
    },
    {
      id: 4,
      key: 'min-merge-time-span',
      parentNode: 'algorithm/lane-change',
      name: '最小汇入时距',
      showType: 'input',
      inputType: 'double',
    },
    {
      id: 5,
      key: 'map-match-angle-factor',
      parentNode: 'algorithm/map-match',
      name: '地图匹配角度因子',
      showType: 'input',
      inputType: 'double',
    },
    {
      id: 6,
      key: 'map-match-distance-factor',
      parentNode: 'algorithm/map-match',
      name: '地图匹配距离因子',
      showType: 'input',
      inputType: 'double',
    },
    {
      id: 7,
      key: 'map-match-inc-thres',
      parentNode: 'algorithm/map-match',
      name: '增量地图匹配阈值',
      showType: 'input',
      inputType: 'double',
    },
    {
      id: 8,
      key: 'map-match-valid-thres',
      parentNode: 'algorithm/map-match',
      name: '地图匹配有效阈值',
      showType: 'input',
      inputType: 'double',
    },
    {
      id: 9,
      key: 'map-valid-time-ms',
      parentNode: 'algorithm/map-match',
      name: '地图有效时长（ms）',
      showType: 'input',
      inputType: 'uint',
    },
    {
      id: 10,
      key: 'app-key',
      parentNode: 'algorithm/ntrip-param',
      name: '差分账号',
      showType: 'input',
      inputType: 'text',
    },
    {
      id: 11,
      key: 'app-pwd',
      parentNode: 'algorithm/ntrip-param',
      name: '差分密码',
      showType: 'input',
      inputType: 'text',
    },
    {
      id: 12,
      key: 'host-name',
      parentNode: 'algorithm/ntrip-param',
      name: '差分服务域名',
      showType: 'input',
      inputType: 'text',
    },
    {
      id: 13,
      key: 'host-port',
      parentNode: 'algorithm/ntrip-param',
      name: '差分服务端口号',
      showType: 'input',
      inputType: 'uint',
    },
    {
      id: 14,
      key: 'is-vaild',
      parentNode: 'algorithm/ntrip-param',
      name: '是否开启差分数据服务',
      showType: 'switch',
      inputType: 'switch',
    },
    {
      id: 15,
      key: 'mount-point',
      parentNode: 'algorithm/ntrip-param',
      name: '挂载点',
      showType: 'input',
      inputType: 'text',
    },
    {
      id: 16,
      key: 'valid',
      parentNode: 'algorithm/dynamic-lane-manage',
      name: '是否开启动态车道管理功能',
      showType: 'switch',
      inputType: 'switch',
    },
    {
      id: 17,
      key: 'lane-info',
      parentNode: 'algorithm/dynamic-lane-manage',
      name: '可变车道信息',
      arr: [],
      showType: ['input', 'input', 'input', 'input', 'input', 'input'],
      inputType: ['number', 'number', 'number', 'number', 'number', 'number'],
    },
    {
      id: 18,
      key: 'b4segment-info',
      parentNode: 'algorithm',
      name: 'B4帧路段映射信息',
      arr: [],
      showType: ['input', 'input', 'arr', 'input', 'input', 'input', 'input', 'input'],
      inputType: 'number',
    },
  ],
}

const data_2 = {
  title: '接收数据清洗',
  data: [
    {
      id: 0,
      key: 'bsmjudge-time',
      parentNode: 'ptcp-msg',
      name: 'BSM消息判断时间戳',
      showType: 'switch',
      inputType: 'switch',
    },
    {
      id: 1,
      key: 'bsm-radius',
      parentNode: 'ptcp-msg',
      name: 'BSM消息半径',
      showType: 'input',
      inputType: 'uint',
    },
    {
      id: 2,
      key: 'time-ahead',
      parentNode: 'ptcp-msg',
      name: '感知消息判断时间戳',
      showType: 'switch',
      inputType: 'switch',
    },
    {
      id: 3,
      key: 'rsmradius',
      parentNode: 'ptcp-msg',
      name: '感知消息范围',
      showType: 'input',
      inputType: 'uint',
    },
    {
      id: 4,
      key: 'time-ahead',
      parentNode: 'ptcp-msg',
      name: '时间戳提前余量',
      showType: 'input',
      inputType: 'uint',
    },
    {
      id: 5,
      key: 'time-delay',
      parentNode: 'ptcp-msg',
      name: '时间戳延后余量',
      showType: 'input',
      inputType: 'uint',
    },
  ],
}

const data_3 = {
  title: 'mec安装信息',
  data: [
    {
      id: 0,
      key: 'node-id',
      parentNode: 'rsu',
      name: 'MEC地图节点ID',
      showType: 'input',
      inputType: 'uint',
    },
    {
      id: 1,
      key: 'region-id',
      parentNode: 'rsu',
      name: 'MEC地图范围ID',
      showType: 'input',
      inputType: 'uint',
    },

    {
      id: 3,
      key: 'rsu-id',
      parentNode: 'rsu',
      name: '设备ID',
      showType: 'input',
      inputType: 'string',
    },
    {
      id: 4,
      key: 'rsu-latitude',
      parentNode: 'rsu',
      name: '设备位置纬度',
      showType: 'input',
      inputType: 'double',
    },
    {
      id: 5,
      key: 'rsu-longitude',
      parentNode: 'rsu',
      name: '设备位置经度',
      showType: 'input',
      inputType: 'double',
    },
  ],
}

const data_4 = {
  title: '本地xml信息',
  data: [
    {
      id: 0,
      key: 'xml-file-path',
      parentNode: 'send-xml-file',
      name: 'MEC地图节点ID',
      showType: 'input',
      inputType: 'number',
    },
    {
      id: 1,
      key: 'file-param',
      arr: [],
      parentNode: 'send-xml-file',
      name: 'XML文件参数信息',
      showType: ['input', 'switch', 'switch', 'input', 'input', 'input', 'input', 'input'],
      inputType: 'number',
    },
  ],
}

const data_main = [data_1, data_2, data_3, data_4]

export const dataProcessing_v2x = (params) => {
  if (!params) return
  // 头部的块
  data_main.forEach((ele) => {
    const data = ele.data
    data.forEach((item) => {
      const keys = item.parentNode.split('/')
      const key1 = keys[0] ?? null
      const key2 = keys[1] ?? null
      if (item.arr) {
        item.arr = key2 ? params[key1][key2][item.key] : params[key1][item.key]
        item.value = []
      } else {
        item.value = key2 ? params[key1][key2][item.key] : params[key1][item.key]
      }
    })
  })

  return { data_main }
}
